import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("自定义显示文本")

    ComboBox {
        anchors.centerIn: parent

        model: [
            { id: 1, name: "苹果", price: 5.8 },
            { id: 2, name: "香蕉", price: 3.2 }
        ]
        textRole: "name"

        displayText: currentText + (currentIndex >= 0 ? " - ¥" + model[currentIndex].price : "")
    }
}
